package com.example.xlmkotlinwanandroid.data.remote.remotedata

import com.example.xlmkotlinwanandroid.network.BaseResponse
import java.lang.Exception

/**
 *  author : cailei
 *  date : 2022/3/18
 *  description :
 */
open class BaseData {
    suspend fun processCall(responseCall: suspend () -> BaseResponse<*>): Any? {
        try {
            val response = responseCall.invoke()

            if (response.errorCode == 0) {
                return response.data
            } else {
                return response.errorCode
            }
        } catch (e: Exception) {
            return NET_WORK_ERROR
        }
    }
}